using System;
using Orders.Entities;
using System.Collections.Generic;
using WCSFContrib.Extensions.CompositeWeb;
using CreateShared.Orders_Module.Interface.Services;
using Microsoft.Practices.CompositeWeb;
using Microsoft.Practices.CompositeWeb.Utility;

namespace CreateShared.Orders_Module
{
    public class Orders_ModuleController : IOrders_ModuleController
    {
        private IOrderService _orderService;
        [ServiceDependency]
        public IOrderService OrderService
        {
            get { return _orderService; }
            set { _orderService = value; }
        }

        protected void OnOrderSelected(DataEventArgs<string> e)
        {
            if (OrderSelected != null)
                OrderSelected(this, e);
        }

        #region IOrders_ModuleController Members

        public IList<Order> RetrieveOrders()
        {
            return OrderService.RetrieveOrders();
        }

        public IList<OrderRow> RetrieveOrderRows(string orderNo)
        {
            return OrderService.RetrieveOrderRows(orderNo);
        }

        public void SelectOrder(string selectedOrderNo)
        {
            OnOrderSelected(new DataEventArgs<string>(selectedOrderNo));
        }

        public event EventHandler<DataEventArgs<string>> OrderSelected;

        #endregion
    }
}
